package com.itheima.api.list.demo03;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ListDemo {
    public static void main(String[] args) {

        Student s1 = new Student("萧忆情", 26);
        Student s2 = new Student("舒靖容", 22);
        Student s3 = new Student("高梦非", 24);

        List<Student> list = new ArrayList<Student>();

        list.add(s1);
        list.add(s2);
        list.add(s3);

        Iterator<Student> iterator = list.iterator();
        while (iterator.hasNext()){
            Student s = iterator.next();
            System.out.println(s.getName() + s.getAge());
        }

        System.out.println("-----------------------------");
        for (Student s : list){
            System.out.println(s);
        }
        System.out.println("-----------------------------");
        for (int i = 0; i < list.size(); i++) {
            Student s = list.get(i);
            System.out.println(s);
        }
        System.out.println("-----------------------------");
    }
}
